﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace V5_EaspLibs.VAction {
    /// <summary>
    /// 
    /// </summary>
    public class VDataRow {
        /// <summary>
        /// 
        /// </summary>
        public string RowName { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string RowValue { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public RowTypeEnum RowType { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public static StringBuilder GetRowUpdate(List<VDataRow> drList) {
            StringBuilder sb = new StringBuilder();
            foreach (var dr in drList) {
                if (dr.RowType == RowTypeEnum.Int32) {
                    sb.Append(" And " + dr.RowName + "=" + dr.RowValue);
                }
                else if (dr.RowType == RowTypeEnum.String
                    || dr.RowType == RowTypeEnum.DataTime) {
                    sb.Append(" And " + dr.RowName + "='" + dr.RowValue + "'");
                }
            }
            if (sb.Length > 0) {
                sb.Remove(0, 4);
            }
            return sb;
        }
    }
    /// <summary>
    /// 
    /// </summary>
    public enum RowTypeEnum {
        /// <summary>
        /// 数字
        /// </summary>
        Int32,
        /// <summary>
        /// 金钱
        /// </summary>
        Decimal,
        /// <summary>
        /// 字符
        /// </summary>
        String,
        /// <summary>
        /// 时间
        /// </summary>
        DataTime,
        /// <summary>
        /// 字段
        /// </summary>
        Field
    }
}
